package gui.pannelInscription;

import java.awt.BorderLayout;


import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import core.Concourt;
import core.Team;

public class PannelInscription extends JPanel implements AddTeam{

	private static final long serialVersionUID = 4177855695204756582L;
	private Concourt concourt;
	private ListTeam listTeam=new ListTeam();
	private JFrame frame;
	private JScrollPane sp;
	
	public PannelInscription(JFrame f,Concourt concourt,ThrowGame tg){
		this.setLayout(new BorderLayout());
		this.concourt=concourt;
		listTeam=new ListTeam();
		add(new InscriptionBar(f,this),BorderLayout.NORTH);	
		sp = new JScrollPane(listTeam);
		add(sp,BorderLayout.CENTER);
		frame=f;
		add(new EndInscriptionButton(tg),BorderLayout.SOUTH);
		Team[] teams=concourt.getClassement();
		for(int i=0;i<teams.length;i++){
			listTeam.add(new JLabel(teams[i].toString()));
		}
	}

	
	
	public void AddNewTeam(String playersNames) {
		Team team=new Team(playersNames);
		concourt.addTeam(team);
		listTeam.add(new JLabel(team.toString()));
		frame.repaint();
		frame.setContentPane(frame.getContentPane());
	}

}
